package leecode

import "sort"

type MinStack struct {
	stack []int
}

/** initialize your data structure here. */
func ConstructorLCR147() MinStack {
	return MinStack{stack: make([]int, 0)}
}

func (this *MinStack) Push(x int) {
	this.stack = append(this.stack, x)
}

func (this *MinStack) Pop() {
	//删除栈顶部的元素
	this.stack = this.stack[:len(this.stack)-1]
}

func (this *MinStack) Top() int {
	return this.stack[len(this.stack)-1]
}

func (this *MinStack) GetMin() int {
	//获取最小的元素
	temp := make([]int, len(this.stack))
	copy(temp, this.stack)
	sort.Ints(temp)
	return temp[0]
}
